package com.gec;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class UploadImage {
    public static void main(String[] args) throws FileNotFoundException {

        // 区域
        String endpoint = "http://oss-cn-guangzhou.aliyuncs.com";

        // 秘钥
        String accessKeyId = "LTAI5tPvx5QG8Jxt5TQdXVt7";
        String accessKeySecret = "OfJhXXfsmjhfimvvHsShfCgGjUr5ZB";

        //创建oss客户端
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

        // 上传文件
        InputStream inputStream = new FileInputStream("E:\\upload\\QQ截图20231130205327.png");
        ossClient.putObject("xinglang", "abc3.jpg", inputStream);

        // 关闭OSSClient。
        ossClient.shutdown();
    }
}
